package com.gitee.zw.rule.utils;

import java.util.Collection;
import java.util.Set;

public class Functions {
    public static boolean containsAny(String csv, Collection<Object> c) {
        if (csv == null || c == null) {
            return false;
        }
        Set ss = Set.of(csv.split(","));
        for (Object s : c) {
            if (ss.contains(String.valueOf(s))) {
                return true;
            }
        }
        return false;
    }

    public static Object decode(Object o, Object... args) {
        for (int i = 0; i < args.length - 1; i += 2) {
            if (args[i].equals(o)) {
                return args[i + 1];
            }
        }
        return args[args.length - 1];
    }
}
